import urllib
from urllib import parse

def str2url(s):
    #s = '9hFaF2FF%_Et%m4F4%538t2i%795E%3pF.265E85.%fnF9742Em33e162_36pA.t6661983%x%6%%74%2i2%22735'
    num_loc = s.find('h')
    rows = int(s[0:num_loc])
    strlen = len(s) - num_loc
    cols = int(strlen/rows)
    right_rows = strlen % rows
    new_s = list(s[num_loc:])
    output = ''
    for i in range(len(new_s)):
        x = i % rows
        y = i / rows
        p = 0
        if x <= right_rows:
            p = x * (cols + 1) + y
        else:
            p = right_rows * (cols + 1) + (x - right_rows) * cols + y
        output += new_s[int(p)]
    return parse.unquote(output).replace('^', '0')


def main():
    s = "6hAFxn625%513E15%8373ea2r65un6i25eb%67uieD2t59ueD63i87f876E62%y3441d4t%sie9FE5E%6%19572.F%m6e4Er%%d%E1553bpetn6s88pr%uDd15n15%8372%3585%4t21at%22E%5428_E3_mc3ie%%%a32%57f7Efesniuu%11si5t%%19%19572.63fe715epF2m%51%62E5F31%62pcD_x352tD63E22%32%_tplp34%_dEi238%38_E3_mvDa%c3Ea%%8i2E159F4%1755673ox_pDE6i2pD49353b2c_%lsD92u%%d6D32D31%62pkB15df7332..F%%E%295876E62%di%i8%do1sf%55E6f6ln3%_146s32%v1761755673e5bE697"
    result_str = str2url(s)
    print(result_str)

if __name__ == '__main__':
    main()
